
<!DOCTYPE html>
<html>
<head lang="en">
	<meta charset="utf-8" />
	<title>购物车</title>
	<link rel="stylesheet" type="text/css" href="css2/public.css"/>
	<link rel="stylesheet" type="text/css" href="css2/proList.css" />
</head>
<body>
	<?php require 'top.php';?>
	


	<?php

	error_reporting(5);
	error_reporting(E_ALL & ~E_NOTICE);
	error_reporting(0);
	header('content-type:text/html;charset=utf-8');

//身份验证
	session_start();
	if (!isset($_SESSION['login'])) {
		header('Refresh:2;url=login/index.php');
		echo "你还没有登陆！";
		die();
	}


	$email=$_SESSION['login'];
	$query_email="SELECT * FROM carts WHERE `uemail`='$email'";
	$result_email=mysqli_query($config,$query_email);
	$row_email=mysqli_fetch_array($result_email);
// echo $row_email['uemail'];
	$user_email=$row_email['buyerid'];




//获取相关信息
// include_once('dbtools.php');
// include_once('config.php');
// 	$link=create_connection();
// 	$sql="select * from carts";
// 	$article=db_getall($link,'school',$sql);

// 获取登录信息
// $email=$_SESSION['login'];
// $query_email="SELECT * FROM carts WHERE `uemail`='$email'";
// $result_email=mysqli_query($config,$query_email);
// $row_email=mysqli_fetch_array($result_email);
// // echo $row_email['uemail'];
// $user_email=$row_email['buyerid'];
// var_dump($user_email);




// // 获取数据库里的用户信息


// $goodskey_id=$_GET['buyerid'];
//     $query = "SELECT * FROM carts WHERE `buyerid`='$goodskey_id'";
//     $result = mysqli_query($config,$query) or die('SQL语句有误：'.mysqli_error());
//     $row=mysqli_fetch_array($result);
// $saler_email=$row['buyerid'];
// var_dump($saler_email);




	$field=$_GET['buyerid'];
	// $fieldbig=$_GET['actbig'];
	if($field!=""){
		$sql="SELECT * FROM carts WHERE `buyerid`='$field' ";
		$result = mysqli_query($config,$sql) or die ('SQL语句有误：'.mysqli_error());
	}




	?>




	<div class="cart mt">
		
		<div class="site">
			<p class=" wrapper clearfix">
				<span class="fl">购物车</span>
				<img class="top" src="img/temp/cartTop01.png">
				<a href="index.php" class="fr">继续购物&gt;</a>
			</p>
		</div>

		
		<!-----------------table------------------->
		<div class="table wrapper">
			<div class="tr">
				<div>商品</div>
				<div>单价</div>
				<div>数量</div>
				<div>小计</div>
				<div>操作</div>
			</div>
			
			

			<?php 
  // if($user_email==$saler_email){
  // 	// echo  'chenggong!';}else{
  // 	// 	echo 'bucehngg';
  // 	// }
  // foreach($article as $k=>$v){


			$sum=0;
			while ($ro=mysqli_fetch_array($result)){
				$sum=$sum+$ro['cost'];

				?>




				<div class="th">
					<div class="pro clearfix">
						<label class="fl">
							<!-- <input type="checkbox"/> -->
							<span></span>
						</label>
						<a class="fl" href="#">
							<dl class="clearfix">
								<dt class="fl" style="width: 140px;height: 120px; "><img src="images/goods/<?php echo $ro['bigtypeid'];?>/<?php echo $ro['smalltypeid'];?>/<?php echo $ro['picture'];?>" style="width: 100%;height: 100%;"></dt>
								<dd class="fl">
									<p style="line-height: 120px;"><?php echo $ro['goodsname'];?></p>
								</dd>
							</dl>
						</a>
					</div>
					<div class="price" style="text-align: center;">￥<?php echo $ro['cost'];?></div>
					<div class="number">
						<p class="num clearfix">
							<img class="fl sub" src="img/temp/sub.jpg">
							<span class="fl">1</span>
							<img class="fl add" src="img/temp/add.jpg">
						</p>
					</div>
					<div class="price sAll" style="text-align: center;">￥<?php echo $ro['cost'];?></div>
					<div class="price" style="text-align: center;"><a class="del" href="cart_delete.php?id=<?php echo $ro['orderid']?>" onclick="return confirm('是否移除该商品？');" style="text-decoration: none;background-color:#aa2116;color: white;font-size: 13px;border-radius: 3px;">移除</a></div>
				</div>
				<?php      
			}
// }
			?>


			<!-- <div class="goOn">空空如也~<a href="index.php">去逛逛</a></div> -->


			<div class="tr clearfix">
					<!-- <label class="fl">
						<input class="checkAll" type="checkbox"/>
						<span></span>
					</label> -->
					<!-- <p class="fl">
						<a href="#">全选</a>
						<a href="#" class="del">删除</a>
					</p> -->
					<p class="fr">
						<!-- <span>共<small id="sl">0</small>件商品</span> -->
						<span>合计:&nbsp;<small id="all">￥<?php echo $sum;?></small></span>
						<a href="order.php?buyerid=<?php echo $user_email;?>"  class="count" style="background-color: #b44747;font-size: 18px;">结算</a>
					</p>
				</div>









			</div>
		</div>
		<!-- <div class="mask"></div> -->
		<!-- <div class="tipDel">
			<p>确定要删除该商品吗？</p>
			<p class="clearfix">
				<a class="fl cer" href="#">确定</a>
				<a class="fr cancel" href="#">取消</a>
			</p>
		</div> -->
		<!----------------mask------------------->
		<!-- <div class="mask"></div> -->
		<!-------------------mask内容------------------->
		<!-- <div class="proDets">
			<img class="off" src="img/temp/off.jpg" />
			<div class="proCon clearfix">
				
				
					<div class="changeBtn clearfix">
						<a href="#2" class="fl"><p class="buy">确认</p></a>
						<a href="#2" class="fr"><p class="cart">取消</p></a>
					</div>
				</div>
			</div>
		</div> -->
		<!-- <div class="pleaseC">
			<p>请选择宝贝</p>
			<img class="off" src="img/temp/off.jpg" />
		</div> -->
		<script src="js2/jquery-1.12.4.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="js2/public.js" type="text/javascript" charset="utf-8"></script>
		<script src="js2/pro.js" type="text/javascript" charset="utf-8"></script>
		<!-- <script src="js2/cart.js" type="text/javascript" charset="utf-8"></script> -->
	</body>
	</html>
